package com.zsc.wxapp.controller.endUser;

import com.zsc.wxapp.context.BaseContext;
import com.zsc.wxapp.entity.dto.OrderPageDTO;
import com.zsc.wxapp.result.PageResult;
import com.zsc.wxapp.result.Result;
import com.zsc.wxapp.entity.vo.UserInfoVO;
import com.zsc.wxapp.services.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;

@RestController("endUserController")
@RequestMapping("/api/wxapp/endUser")
//@Api(tags = "C端-用户相关接口")
@Slf4j
public class UserController {

    @Resource
    private UserService userService;


    /**
     * 获取用户详细信息
     * @return userInfoVO
     */
    @GetMapping("/getUseInfo")
//    @ApiOperation("获取用户详细信息")
    public Result<UserInfoVO> getUserInfo() {
        Long userId = BaseContext.getCurrentId();
        UserInfoVO userinfo = userService.getUserInfo(userId);
        return Result.success(userinfo);
    }

    /**
     * 获取订单列表
     * @param orderPageDTO 分页查询接收类
     * @return Result
     */
    @GetMapping("/getOrderList")
//    @ApiOperation("获取订单列表")
    public Result<PageResult> getOrderList(OrderPageDTO orderPageDTO) {
        log.info("获取订单列表，orderPageDTO：{}", orderPageDTO);
        PageResult pageResult = userService.orderPage(orderPageDTO);
        return Result.success(pageResult);
    }

    /**
     * 根据type来更新用户的次数信息
     * @param type 类型
     */
    @PutMapping("updateUserInfo")
//    @ApiOperation("更新用户次数信息")
//    @ApiImplicitParam(name = "type", value = "类型:1是打印次数，2是反馈次数", required = true, dataTypeClass = Integer.class)
    public Result<?> updateUserTimes(Integer type) {
        log.info("更新用户次数信息，type：{}", type);
        userService.updateUserTimes(type);
        return Result.success();
    }
}
